package kxfang.com.common.bean;

import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;

import androidx.databinding.BaseObservable;
import androidx.databinding.Bindable;

import kxfang.com.common.BR;
import kxfang.com.common.parameter.TokenModel;


/**
 * 接收和请求地址model
 */
public class AddressPack extends BaseObservable implements Parcelable {

    private String ID;
    private String Receiver;//收货人
    private String Sex;
    private String Phone;
    private String City;
    private String Address;//详细地址
    private String HouseNum;//楼号门牌号
    private String Label;//标签
    private String RUserID;
    private String WebID;
    private TokenModel tokenModel;
    private boolean isCheck;// 自己使用，不是后台返回
    private int PageIndex;
    private int PageSize;
    private int IsDefault;//是否是默认地址
    private String Lat;
    private String Lng;

    public String getLat() {
        return Lat;
    }

    public void setLat(String lat) {
        Lat = lat;
    }

    public String getLng() {
        return Lng;
    }

    public void setLng(String lng) {
        Lng = lng;
    }

    public boolean isCheck() {
        return isCheck;
    }

    public void setCheck(boolean check) {
        isCheck = check;
    }

    public int getPageIndex() {
        return PageIndex;
    }

    public void setPageIndex(int pageIndex) {
        PageIndex = pageIndex;
    }

    public int getPageSize() {
        return PageSize;
    }

    public void setPageSize(int pageSize) {
        PageSize = pageSize;
    }

    public AddressPack() {
    }

    protected AddressPack(Parcel in) {
        ID = in.readString();
        Receiver = in.readString();
        Sex = in.readString();
        Phone = in.readString();
        City = in.readString();
        Address = in.readString();
        HouseNum = in.readString();
        Label = in.readString();
        RUserID = in.readString();
        WebID = in.readString();
        IsDefault = in.readInt();
        Lat = in.readString();
        Lng = in.readString();
    }

    public static final Creator<AddressPack> CREATOR = new Creator<AddressPack>() {
        @Override
        public AddressPack createFromParcel(Parcel in) {
            return new AddressPack(in);
        }

        @Override
        public AddressPack[] newArray(int size) {
            return new AddressPack[size];
        }
    };

    public TokenModel getTokenModel() {
        return tokenModel;
    }

    public void setTokenModel(TokenModel tokenModel) {
        this.tokenModel = tokenModel;
    }

    public String getID() {
        return ID;
    }

    public void setID(String ID) {
        this.ID = ID;
    }

    @Bindable
    public String getReceiver() {
        return Receiver;
    }

    public void setReceiver(String Receiver) {
        this.Receiver = Receiver;
        notifyPropertyChanged(BR.receiver);
    }

    public String getSex() {
        return Sex;
    }

    public void setSex(String Sex) {
        this.Sex = Sex;
    }

    @Bindable
    public String getPhone() {
        return Phone;
    }

    public void setPhone(String Phone) {
        this.Phone = Phone;
        notifyPropertyChanged(BR.phone);
    }

    @Bindable
    public String getCity() {
        return City;
    }

    public void setCity(String City) {
        this.City = City;
        notifyPropertyChanged(BR.city);
    }

    @Bindable
    public String getAddress() {
        return Address;
    }

    public void setAddress(String Address) {
        this.Address = Address;
        notifyPropertyChanged(BR.address);
    }

    @Bindable
    public String getHouseNum() {
        return HouseNum;
    }

    public void setHouseNum(String HouseNum) {
        this.HouseNum = HouseNum;
        notifyPropertyChanged(BR.houseNum);
    }

    public String getLabel() {
        return Label;
    }

    public void setLabel(String Label) {
        this.Label = Label;
    }

    public String getRUserID() {
        return RUserID;
    }

    public void setRUserID(String RUserID) {
        this.RUserID = RUserID;
    }

    public String getWebID() {
        return WebID;
    }

    public void setWebID(String WebID) {
        this.WebID = WebID;
    }

    public int isDefault() {
        return IsDefault;
    }

    public void setDefault(int aDefault) {
        IsDefault = aDefault;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(ID);
        dest.writeString(Receiver);
        dest.writeString(Sex);
        dest.writeString(Phone);
        dest.writeString(City);
        dest.writeString(Address);
        dest.writeString(HouseNum);
        dest.writeString(Label);
        dest.writeString(RUserID);
        dest.writeString(WebID);
        dest.writeInt(IsDefault);
        dest.writeString(Lat);
        dest.writeString(Lng);
    }

    public String getCompleteAddress() {
//        return City + " " + Address + HouseNum;
        return Address;
    }

    /**
     * 是否显示标签
     * @return
     */
    public boolean hasLabel(){
        if(TextUtils.isEmpty(Label)){
            return false;
        }
        return true;
    }
}
